/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class reverse {
    public int reverse(int x) {
        int digit  = 0, rec = 0;
        while (x != 0){
            digit  = x % 10;
            x = x / 10;
            if (rec > Integer.MAX_VALUE /10 - digit || rec < Integer.MIN_VALUE /10 - digit){
                return 0;
            }
            rec = rec * 10 + digit;
        }
        return rec;
    }

}
